<template>
  <view class="community">
    <view class="top">
      <uv-navbar title="师傅列表" bgColor="#65c9bb" height="66px" titleStyle="{font-weight: bold;font-size: 1.1rem;}"
        @click="goback"></uv-navbar>
    </view>
    <!-- 选项卡 -->
    <view class="tabs">
      <uv-tabs :list="list" lineColor="#149494" activeStyle=" color:#149494" :scrollable="false"
        @click="click"></uv-tabs>
    </view>

    <!-- 综合 -->
    <view v-if="current== 0">
      <view class="boxbox1">
        <view class="recommend-bottom1" @click="gomaster(item.id)" v-for="(item,index) in list1" :key="item.id">
          <view class="bottom-top1">
            <view class="photo">
              <image class="image2" src="/static/image/宠物医生.png" mode=""></image>
              <view class="shadow">上次服务</view>
            </view>
            <view class="text1">{{item.name}}</view>
            <view class="text2">已服务:{{item.num}}次</view>
          </view>
        </view>
      </view>
    </view>

    <!-- 点赞 -->
    <view v-if="current== 1">
      <view class="boxbox1">
        <view class="recommend-bottom1" @click="gomaster(item.id)" v-for="(item,index) in list2" :key="item.id">
          <view class="bottom-top1">
            <view class="photo">
              <image class="image2" src="/static/image/宠物医生.png" mode=""></image>
              <view class="shadow">上次服务</view>
            </view>
            <view class="text1">{{item.name}}</view>
            <view class="text2">已服务:{{item.num}}次</view>
          </view>
        </view>
      </view>
    </view>
    <view v-if="current== 2">
      <view class="boxbox1">
        <view class="recommend-bottom1" @click="gomaster(item.id)" v-for="(item,index) in list3" :key="item.id">
          <view class="bottom-top1">
            <view class="photo">
              <image class="image2" src="/static/image/宠物医生.png" mode=""></image>
              <view class="shadow">上次服务</view>
            </view>
            <view class="text1">{{item.name}}</view>
            <view class="text2">已服务:{{item.num}}次</view>
          </view>
        </view>
      </view>
    </view>
    <view v-if="current== 3">
      <view class="boxbox1">
        <view class="recommend-bottom1" @click="gomaster(item.id)" v-for="(item,index) in list4" :key="item.id">
          <view class="bottom-top1">
            <view class="photo">
              <image class="image2" src="/static/image/宠物医生.png" mode=""></image>
              <view class="shadow">上次服务</view>
            </view>
            <view class="text1">{{item.name}}</view>
            <view class="text2">已服务:{{item.num}}次</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    uniRequest
  } from "../../utils/request.js"
  export default {
    data() {
      return {
        current: '',
        list: [{
          name: '综合',
        }, {
          name: '距离',
        }, {
          name: '服务次数',
        }, {
          name: '好评',
        }],
        list1: '',
        list2: '',
        list3: '',
        list4: '',
      }
    },
    created() {
      // 综合
      const that = this
      uniRequest('master/list1?server=1', function(err, data) {
        if (err) {
          // 错误
          console.log(err)
        } else {
          console.log('"成功了"', data)
          that.list1 = data.list
          console.log(that.list1)
        }
      }, 'GET', {});
      // 距离
      uniRequest('master/list2?server=1', function(err, data) {
        if (err) {
          // 错误
          console.log(err)
        } else {
          console.log('"成功了"', data)
          that.list2 = data.list
          console.log(that.list2)
        }
      }, 'GET', {});
      // 服务次数
      uniRequest('master/list3?server=1', function(err, data) {
        if (err) {
          // 错误
          console.log(err)
        } else {
          console.log('"成功了"', data)
          that.list3 = data.list
          console.log(that.list3)
        }
      }, 'GET', {});
      // 好评
      uniRequest('master/list4?server=1', function(err, data) {
        if (err) {
          // 错误
          console.log(err)
        } else {
          console.log('"成功了"', data)
          that.list4 = data.list
          console.log(that.list4)
        }
      }, 'GET', {});
    },
    methods: {
      // 跳转师傅推荐
      gomaster(id) {
        uni.navigateTo({
          url: `/pages/masterdetails/masterdetails?id=${JSON.stringify(id)}`
        })
      },
      goback() {
        uni.navigateBack({
          delta: 1
        });
      },
      click(item) {
        this.current = item.index
        console.log('item', item.index);
      }
    }
  }
</script>

<style lang="scss">
  @import url("listmasters.scss");
</style>